package view.toolboxComponents;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import controller.CustomEvent;
import controller.ToolBoxEventHandler;
/** * A class to encapsulate the object fill panel on the designer * @author Daniel Bond, Mohammed Abdullah, Gideon Pyzer */
@SuppressWarnings("serial")
public class PrescriptionObjectFillPanel extends AbstractPanel{
	private JLabel lblFillColour;
	private JButton btnFillColour;
	private ToolBoxEventHandler eventHandler;	
	public PrescriptionObjectFillPanel(){		
		super();
		eventHandler = new ToolBoxEventHandler();		
		btnFillColour = new JButton();
		btnFillColour.setPreferredSize(new Dimension(12,12));
		btnFillColour.setMaximumSize(new Dimension(12,12));
		btnFillColour.setToolTipText("Fill colour of Box");
		lblFillColour = new JLabel("Fill Colour");
		//Changes the fill colour of the selected object, only if it is a box
		btnFillColour.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				CustomEvent event = new CustomEvent("presObjectFillColourChange", PrescriptionObjectFillPanel.this);
				PrescriptionObjectFillPanel.this.eventHandler.createEvent(event);
			}
		});
		buildPanel();
	}	/**	 * Sets the button background colour	 * @param c an {@link java.awt.Color} object that is set to be the background colour of the button	 */
	public void setButtonBackgroundColour(Color c){
		btnFillColour.setBackground(c);
	}
	/**
	 * Build prescription name panel
	 */
	private void buildPanel() {
		this.add(lblFillColour);
		makeRigidArea();
		this.add(btnFillColour);
	}	@Override
	public void resetComponent() {
		btnFillColour.setBackground(null);
	}
}